home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / moonphas.tar / moonphaseimpr < prev   
Internet Message Format  |  1990-08-24  |  4KB

  1. From gerson@parc.xerox.com Fri Jul 13 09:10:34 1990
  2. From: gerson@parc.xerox.com (Dan Gerson)
  3. Newsgroups: comp.sys.handhelds
  4. Subject: More accurate phase of the moon program
  5. Date: 12 Jul 90 01:26:51 GMT
  6. Distribution: comp
  7. Organization: Xerox PARC, Palo Alto, CA
  8.  
  9.  
  10. Here is an improved program to calculate and display the phase of the moon.  It
  11. uses the drawing routines provided by Craig Finseth's phase of the moon program,
  12. (with the modifications to FLIP as suggested by Preston Brown and Juri Munkki),
  13. but has an adapted version of the very complicated phase calcuation in John
  14. Walker's moontool application on the SUN.  The HP48SX results are exactly the
  15. same as those obtained from Moontool, which appear to be extremely accurate,
  16. unlike the previous moon phase program.
  17.  
  18. To use it, you have to write out your current time difference from UTC in a
  19. TMZN global variable somewhere; I have my system setup with TMZN stored in { HOME }
  20. so it is available to other programs I use.  Otherwise, you can just put it
  21. in the same directory as your put { JDAT }.  For example, the correct value for
  22. California is currently 7.
  23.  
  24. Then {MPHASE} displays the current phase of the moon graphically using Craig Finseth's
  25. code, {MTIME} returns a string containing the number of days, hours, and minutes
  26. >from the last new moon along with the current percentage of the moon which is
  27. illuminated, {MFRAC} returns the illuminated percentage to level 2 and the
  28. percentage of the moon's age since the last new moon in level 1, and finally,
  29. {JDAT} return the current civil julian date and fraction of the day (UTC).
  30.  
  31. Checksum: #D058h (I think - I tend to edit the text on my mac sometimes.)
  32. Size: 2002
  33. ------------------------------------------------------------
  34. %%HP: T(3)A(D)F(.);
  35. DIR
  36.   MPHASE
  37.     \<< RCLF -31 SF
  38. DEG ERASE { # 0h
  39. # 0h } PVIEW {
  40. # 40h # 1Ch } # 1Ah
  41. 0 360 ARC 26 28
  42. MFRAC SWAP DROP
  43. MPLOT MFINI 7
  44. FREEZE STOF
  45.     \>>
  46.   MTIME
  47.     \<< MFRAC \-> PCT X
  48.       \<< X
  49. 29.53058868 * DUP
  50. 'X' STO IP "d " + X
  51. FP 24 * IP + "h " +
  52. X FP 1440 * 60 MOD
  53. IP + "m (" + PCT
  54. 100 * 0 RND + "%)"
  55. +
  56.       \>>
  57.     \>>
  58.   MFRAC
  59.     \<< RCLF 0 0 0 0
  60. 0 0 JDAT 2444239 -
  61. \-> FLGS M ML MM EV
  62. AE A3 day
  63.       \<< RAD day
  64. .985647332099 * 360
  65. MOD -3.762863 + 360
  66. MOD D\->R 'M' STO 'E=
  67. .016718*SIN(E)+M'
  68. 'E' M ROOT 2 / TAN
  69. 1.01686011182 *
  70. ATAN R\->D 2 *
  71. 282.596403 + 360
  72. MOD 'E' STO
  73. 13.1763966 day *
  74. 64.975464 + 360 MOD
  75. DUP 'ML' STO
  76. .1114041 day * -
  77. 349.383063 - 360
  78. MOD 'MM' STO ML E -
  79. 2 * MM - D\->R SIN
  80. 1.2739 * 'EV' STO M
  81. SIN DUP .1858 *
  82. 'AE' STO .37 * 'A3'
  83. STO MM EV + AE - A3
  84. - DUP D\->R SIN
  85. 6.2886 * SWAP 2 *
  86. D\->R SIN .214 * SWAP
  87. EV + ML + AE - +
  88. DUP E - 2 * D\->R SIN
  89. .6583 * + E - DUP
  90. D\->R COS NEG 1 + 2 /
  91. 'Illuminated' \->TAG
  92. SWAP 360 / 'Age'
  93. \->TAG FLGS STOF
  94.       \>>
  95.     \>>
  96.   JDAT
  97.     \<< 1.01198 DATE
  98. DDAYS 2444240 +
  99. TIME HMS\-> TMZN + 24
  100. / +
  101.     \>>
  102.   MPLOT
  103.     \<< \-> RA MI F
  104.       \<<
  105.         IF F .5 <
  106.         THEN F 360
  107. * COS RA * RA
  108.         ELSE RA NEG
  109. F .5 - 360 * COS RA
  110. *
  111.         END \-> L R
  112.         \<< 1 0
  113.           FOR x x
  114. ACOS SIN DUP MI x
  115. RA * + L R MLINE MI
  116. x RA * - L R MLINE
  117. RA INV NEG
  118.           STEP
  119.         \>>
  120.       \>>
  121.     \>>
  122.   MLINE
  123.     \<< \-> SC LI L R
  124.       \<< SC L * 64 +
  125. R\->B LI R\->B 2 \->LIST
  126. SC R * 64 + R\->B LI
  127. R\->B 2 \->LIST LINE
  128.       \>>
  129.     \>>
  130.   MFINI
  131.     \<< { # Ah # Ah }
  132. PIXON { # 6Eh # Fh
  133. } PIXON { # 64h
  134. # 32h } PIXON {
  135. # 1Eh # 29h } PIXON
  136. { # 1Fh # 29h }
  137. PIXON PICT NEG
  138.     \>>
  139.   SLOFLIP
  140.     \<< 0 63
  141.       FOR l # 0h l
  142. R\->B 2 \->LIST # 82h l
  143. R\->B 2 \->LIST TLINE
  144.       NEXT
  145.     \>>
  146.   E 109.444275789
  147. END
  148.  
  149.